package com.company.Lab1;

import java.util.Scanner;

public class Pesimist {
    public static void main(String[] args) {
        int pesimintArr[][];
        int rmin[] = new int[10];
        int maxiMin = 0;
        Scanner scanner = new Scanner(System.in);
        int r, c;

        System.out.println("Introducerti numarul de randuri : ");
        r = scanner.nextInt();
        System.out.println("Introduceti numarul de coloane : ");
        c = scanner.nextInt();

        pesimintArr = new int[r][c];

        System.out.println("Introduceti datele matrcii :");

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                System.out.print("[" + i + "][" + j + "] : ");
                pesimintArr[i][j] = scanner.nextInt();
            }
        }

        //calculele
        for (int i = 0; i < r; i++) {
            int min = pesimintArr[i][1];
            for (int j = 0; j < c; j++) {
                if (min >= pesimintArr[i][j]) {
                    min = pesimintArr[i][j];
                }
            }
            rmin[i] = min;
        }
        System.out.println("Valorile minime pe rand sunt : ");
        for (int i = 0; i < r; i++) {
            System.out.println(rmin[i] + "\t");
        }
        //Maximul din minim
        int maxMin = rmin[1];
        for (int i = 0; i < r; i++) {
            maxMin = Math.max(maxMin,rmin[i]);
        }
        maxiMin = maxMin;
        System.out.println("Valoarea maximin : " + maxiMin);
    }

}

